@rien7/seji 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/seji.mjs CHANGED
@@ -175,6 +175,18 @@ const countBy = (items, status) =>
175
175
  const command = process.argv[2]
176
176
  const arg = process.argv[3]
177
177
 
178
+ // `seji <command> [<sub>] --help | -h`: that command's lines of the usage, exit 0 (before the
179
+ // updater and before any option parsing, which would reject the flag).
180
+ if (command && !command.startsWith('-') && command !== 'help' && process.argv.slice(3).some((token) => token === '--help' || token === '-h')) {
181
+ const name = command === 'init' ? 'setup' : command
182
+ const lines = usage.split('\n').filter((line) => line.startsWith(` seji ${name} `) || line === ` seji ${name}`)
183
+ const sub = arg && !arg.startsWith('-') ? lines.filter((line) => line.startsWith(` seji ${name} ${arg} `) || line === ` seji ${name} ${arg}`) : []
184
+ if (lines.length) {
185
+ console.log(`Usage:\n${(sub.length ? sub : lines).join('\n')}\n\nseji --help lists every command.`)
186
+ process.exit(0)
187
+ }
188
+ }
189
+
178
190
  {
179
191
  // Always latest: one owner (cli/updater.mjs). When it re-ran the command on a newer version,
180
192
  // that run's exit code is ours.
package/dist/cli/dev.mjs CHANGED
@@ -245,6 +245,15 @@ function designDirLabel(dir, { cwd, base }) {
245
245
  return `${shown}/${where}`
246
246
  }
247
247
 
248
+ /** The lines `seji dev` prints once listening, labels padded to one column. */
249
+ export function devBanner({ designUrl, localUrl, networkUrl }) {
250
+ const rows = [['seji ready:', designUrl]]
251
+ if (localUrl) rows.push(['App preview:', localUrl])
252
+ if (networkUrl && networkUrl !== localUrl) rows.push(['Network:', `${networkUrl.replace(/\/$/, '')}/__seji`])
253
+ const width = Math.max(...rows.map(([label]) => label.length)) + 1
254
+ return `\n${rows.map(([label, value]) => ` ${label.padEnd(width)}${value}`).join('\n')}\n`
255
+ }
256
+
248
257
  /** One line when the app's own design/ is used and another design dir is ignored. */
249
258
  export function twoDesignDirsWarning({ cwd = process.cwd(), base, inUse, ignored }) {
250
259
  return `seji: found two design directories: ${designDirLabel(inUse, { cwd, base })} (in use) and ${designDirLabel(ignored, { cwd, base })} (ignored). Remove one of them.`
@@ -311,12 +320,7 @@ export async function startDevServer({ root: cwd = process.cwd(), argv = [] } =
311
320
  const baseUrl = localUrl ?? networkUrl ?? `http://localhost:${activePort}/`
312
321
  const designUrl = `${baseUrl.replace(/\/$/, '')}/__seji`
313
322
 
314
- console.log(`\n seji ready: ${designUrl}`)
315
- if (localUrl) console.log(` App preview: ${localUrl}`)
316
- if (networkUrl && networkUrl !== localUrl) {
317
- console.log(` Network: ${networkUrl.replace(/\/$/, '')}/__seji`)
318
- }
319
- console.log('')
323
+ console.log(devBanner({ designUrl, localUrl, networkUrl }))
320
324
 
321
325
  let closing = false
322
326
  const shutdown = async () => {
@@ -95,14 +95,19 @@ const globBase = (pattern) => {
95
95
  return parts.join('/') || '.'
96
96
  }
97
97
 
98
- function pathsCheck(root) {
98
+ /**
99
+ * surface.config.json `css` and component globs are Vite-root paths (the app: the plugin serves
100
+ * and scans them from there), also when design/ sits outside the app (a 0.4.2 repo keeps it at
101
+ * the repository root). tokens.config.json paths are relative to the design dir's parent.
102
+ */
103
+ function pathsCheck(root, appRoot = root) {
99
104
  const missing = []
100
105
  const surface = readJson(join(root, 'design/surface.config.json'))
101
- for (const css of surface?.css ?? []) if (!existsSync(join(root, String(css).replace(/^\//, '')))) missing.push(`surface.config.json css ${css}`)
106
+ for (const css of surface?.css ?? []) if (!existsSync(resolve(appRoot, String(css).replace(/^\//, '')))) missing.push(`surface.config.json css ${css}`)
102
107
  for (const group of surface?.componentGroups ?? []) {
103
108
  for (const pattern of group.globs ?? []) {
104
109
  if (String(pattern).startsWith('!')) continue
105
- if (!existsSync(join(root, globBase(String(pattern))))) missing.push(`surface.config.json glob ${pattern}`)
110
+ if (!existsSync(resolve(appRoot, globBase(String(pattern))))) missing.push(`surface.config.json glob ${pattern}`)
106
111
  }
107
112
  }
108
113
  const tokens = readJson(join(root, 'design/tokens.config.json'))
@@ -251,7 +256,7 @@ export async function runDoctor({ root: cwd = process.cwd(), app, designDir: for
251
256
  checks.push(check('vite-config', 'fail', `${vite.file} mounts designPlugin but ${DESIGN_PACKAGE} is not installed in the app`, `remove designPlugin from ${vite.file} (\`${CLI} dev\` mounts it) or install ${DESIGN_PACKAGE}`))
252
257
  } else checks.push(check('vite-config', 'ok', `${vite.file} loads${vite.designPlugin ? ' (mounts designPlugin itself)' : ''}`))
253
258
 
254
- checks.push(pathsCheck(root))
259
+ checks.push(pathsCheck(root, appRoot))
255
260
  const styles = appStyles(appRoot, { aliases: vite.ok ? vite.aliases : [], tailwindPlugin: vite.ok && vite.tailwind })
256
261
  const cssRel = styles.stylesheets.map((file) => relative(root, file).split('\\').join('/'))
257
262
  const tokens = await tokensChecks(root, cssRel)
@@ -326,6 +326,9 @@ async function setupExistingDesign({ cwd, found, design, dryRun, deep, home, env
326
326
  if (swapped.length) todos.push(`${swapped[0].file} now depends on ${DESIGN_PACKAGE} instead of @rien7/design-surface: run the package install`)
327
327
  }
328
328
  results.push(ensureCacheGitignore(design.home, { dryRun }))
329
+ // The 0.4.2 layout (generated files in design/, .consolidate/, sessions) is migrated here too:
330
+ // doctor's `layout` check points to setup for exactly this kind of design dir.
331
+ results.push(...migrateLayout(design.home, { dryRun }))
329
332
  results.push(...[await ensureDesignTypes(design.home, { dryRun })].flat())
330
333
  if (!dryRun && existsSync(join(design.designDir, 'tokens'))) {
331
334
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/editor/App.tsx"],"names":[],"mappings":"AA6TA,wBAAgB,GAAG,gCA6nHlB"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/editor/App.tsx"],"names":[],"mappings":"AA6TA,wBAAgB,GAAG,gCA+nHlB"}
@@ -2017,6 +2017,7 @@ export function App() {
2017
2017
  items: pending,
2018
2018
  batchId: batch.id,
2019
2019
  missingComponents: missing,
2020
+ locale,
2020
2021
  });
2021
2022
  const task = navigator.clipboard?.writeText(text) ??
2022
2023
  Promise.reject(new Error('Clipboard unavailable'));
@@ -2026,7 +2027,7 @@ export function App() {
2026
2027
  window.setTimeout(() => setCopied(false), 1500);
2027
2028
  })
2028
2029
  .catch(() => setError(t('error.clipboard')));
2029
- }, [componentCatalog, componentPages, design, designId, flushReviewOps, queueReviewOps, t]);
2030
+ }, [componentCatalog, componentPages, design, designId, flushReviewOps, locale, queueReviewOps, t]);
2030
2031
  /** The Agent tab in front (not on the changes page, which has no right panel). */
2031
2032
  const showAgentPanel = useCallback(() => {
2032
2033
  setRightTab('agent');
@@ -2068,6 +2069,7 @@ export function App() {
2068
2069
  items: pending,
2069
2070
  batchId: batch.id,
2070
2071
  missingComponents: missingComponentPages(componentCatalog, (name) => Boolean(componentPages[name])),
2072
+ locale,
2071
2073
  }),
2072
2074
  handoff: { design: designId, itemIds: batch.itemIds, batchId: batch.id },
2073
2075
  context: agentContextRef.current,
@@ -2076,7 +2078,7 @@ export function App() {
2076
2078
  catch (sendError) {
2077
2079
  setError(sendError instanceof Error ? sendError.message : String(sendError));
2078
2080
  }
2079
- }, [agent.available, componentCatalog, componentPages, copyPrompt, design, designId, flushReviewOps, queueReviewOps, showAgentPanel]);
2081
+ }, [agent.available, componentCatalog, componentPages, copyPrompt, design, designId, flushReviewOps, locale, queueReviewOps, showAgentPanel]);
2080
2082
  const activateFrame = useCallback((pageId, frameId) => {
2081
2083
  const page = pages.find((item) => item.id === pageId);
2082
2084
  const frame = page?.frames.find((item) => item.id === frameId);